package com.education.wisdom.controller.management;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.education.common.utils.ApiReturnObject;
import com.education.wisdom.pojo.CurrencyRecord;
import com.education.wisdom.service.ICurrencyRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/web/currencyRecord")
public class CurrencyRecordController {

    @Autowired
    private ICurrencyRecordService currencyRecordService;

    /**
     * 达人币支付记录
     *
     * @return
     */
    @GetMapping("/details")
    public ApiReturnObject details(CurrencyRecord currencyRecord, Integer pageNum, Integer pageSize) {
        if (pageNum != null && pageSize != null){
            PageHelper.startPage(pageNum,pageSize);
        }
        List<CurrencyRecord> currencyRecordList = currencyRecordService.selectCurrencyRecordList(currencyRecord);
        PageInfo<CurrencyRecord> pageInfo = new PageInfo<>(currencyRecordList);
        return new ApiReturnObject("200", "操作成功", pageInfo);
    }

    /**
     * 删除
     */
    @DeleteMapping("/deleteById")
    public ApiReturnObject deleteById(Integer id) {
        int i = currencyRecordService.deleteCurrencyRecordById(id);
        return new ApiReturnObject("200", "操作成功", "操作成功");
    }
}
